package com.zbkj.crmeb.enums;

import java.util.Objects;

import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * 业务类型-注册申请
 * @author daigb
 * @date:  2022-07-26 10:26
 */
public enum BusinessApplyCodeEnum implements IEnum<Integer> {

	/**
	 * 酒庄注册申请
	 */
    WINERY(1, "winery", "酒庄注册申请"),

    ;

    private final Integer code;
    private final String name;
    private final String msg;

    BusinessApplyCodeEnum(int code, String name, String msg) {
        this.code = code;
        this.name = name;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public String getName() {
        return name;
    }

    @JsonCreator
    public static BusinessApplyCodeEnum valueOf(Integer code) {
        for (BusinessApplyCodeEnum value : values()) {
            if (code.equals(value.getCode())) {
                return value;
            }
        }
        return BusinessApplyCodeEnum.WINERY;
    }

    @Override
    @JsonValue
    public Integer getValue() {
        return code;
    }

    public static BusinessApplyCodeEnum getEnumByCode(Integer code) {
        for (BusinessApplyCodeEnum value : values()) {
            if (Objects.equals(value.getCode(), code)) {
                return value;
            }
        }
        return WINERY;
    }

    public static String getMsgByCode(Integer code) {
        for (BusinessApplyCodeEnum value : values()) {
            if (Objects.equals(value.getCode(), code)) {
                return value.msg;
            }
        }
        return WINERY.msg;
    }
    public static String getNameByCode(Integer code) {
        for (BusinessApplyCodeEnum value : values()) {
            if (Objects.equals(value.getCode(), code)) {
                return value.name;
            }
        }
        return WINERY.name;
    }
}

